
package physical_spaces.DAO;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author JuanFelipe
 */
public class ManagementDataFileDAO {
    public Connection conn;

    public ManagementDataFileDAO(Connection conn) {
        this.conn = conn;
    }
    
    public ResultSet executeStatement( String sql ) {
        
        try {
            System.out.println( sql );
            Statement statement = conn.createStatement();
            ResultSet resultSet = statement.executeQuery( sql );
            return resultSet;
        } catch (SQLException e) {
            System.out.println(e.getMessage());
            return null;
        }
    }

    public String reSizeDataFile(String query) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(query);
            stmt.close();
            return "Tamaño de DataFile modificado exitosamente";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
    }
    
    public String reSizeTempFile(String query) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(query);
            stmt.close();
            return "Tamaño de TempFile modificado exitosamente";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
    }
    
    public String eliminarDataFile(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "DataFile eliminado Exitosamente";

        } catch (Exception e) {
            return e.getMessage();
        }
        
    }
    
    public String eliminarTempFile(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "TempFile eliminado Exitosamente";

        } catch (Exception e) {
            return e.getMessage();
        }
        
    }
}
